<% variant_id = f.object.variant&.id || 'VARIANT_ID' %>
<% location_id ||= 'DESTINATION_ID' %>

<div class="d-flex align-items-center justify-content-between nested-form-wrapper" data-new-record="true">
  <%= f.hidden_field :variant_id, value: variant_id %>
  <%= f.hidden_field :stock_item_id %>
  <%= f.hidden_field :location_id, data: { stock_transfer_target: "destinationInput" }, value: location_id %>
  <div class="d-flex align-items-center gap-2">
    <% if f.object.variant.present? %>
      <%= render 'spree/admin/shared/product_image', object: f.object.variant %>
    <% else %>
      VARIANT_IMAGE
    <% end %>
    <div class="d-flex flex-column align-items-start justify-content-center">
      <% if f.object.variant.present? %>
        <%= f.object.variant.name %>
        <% if f.object.variant.sku.present? %>
          <span class="text-muted"><strong><%= Spree.t(:sku) %>:</strong> <%= f.object.variant.sku %></span>
        <% end %>

        <span class="text-muted">
          <%= "(#{f.object.variant.options_text})" if f.object.variant.options_text.present? %>
        </span>
      <% else %>
        VARIANT_INFO
      <% end %>
    </div>
  </div>
  <div class="d-flex align-items-center gap-2">
    <%= f.number_field :quantity, class: 'form-control w-auto', value: f.object.quantity.zero? ? 1 : f.object.quantity, required: true, min: 1, data: { action: "stock-transfer#updateQuantity", variant_id: variant_id } %>
    <%= button_tag class: 'btn btn-sm btn-danger', type: :button, data: { action: 'stock-transfer#remove', variant_id: variant_id } do %>
      <%= icon('trash', class: 'icon icon-trash') %>
      <%= Spree.t(:remove) %>
    <% end %>
  </div>
</div>
